package co.th.bjc.md.dbonline.control;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

import co.th.bjc.md.dbonline.bean.CategoryDBOnlineBean;
import co.th.bjc.md.helper.CategoryHelper;
import co.th.bjc.md.model.Category;

public class CategoryDBOnlineControl {

	private static Logger _log = Logger.getLogger(CategoryDBOnlineControl.class);
	
	public List<CategoryDBOnlineBean> findAllCategory() {
		List<CategoryDBOnlineBean> list = new ArrayList<CategoryDBOnlineBean>(0);
		try {
			List<Category> listCategory = new CategoryHelper().findAllCategory();
			for (Category category : listCategory) {
				list.add(setModelToBean(category));
			}
		} catch (Exception ex) {
			_log.error("Exception : " + ex.getMessage());
			ex.printStackTrace();
		}
		return list;
	}
	
	private CategoryDBOnlineBean setModelToBean(Category model){
		CategoryDBOnlineBean bean = new CategoryDBOnlineBean();
		bean.setCategoryCode(model.getCategoryCode().intValue());
		bean.setCategoryNameTH(model.getCategoryNameTh());
		bean.setCategoryNameEN(model.getCategoryNameEn());
		return bean;
	}
	
//	private Department setBeanToModel(DepartmentDBOnlineBean bean){
//		Department model = new Department();
//		model.setDepartmentCode(BigDecimal.valueOf(bean.getDepartmentCode()));
//		model.setDepartmentNameEN(bean.getDepartmentNameEN());
//		model.setDepartmentNameTH(bean.getDepartmentNameTH());
//		model.setDepartmentDetail(bean.getDepartmentDetail());
//		model.setExpertises(null);
//		model.setCreateBy(null);
//		model.setCreateDate(null);
//		model.setUpdateBy(null);
//		model.setUpdateDate(null);
//		return model;
//	}
}
